<?
include("../lib/config.php");
$nik 	= $HTTP_GET_VARS['nik'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];
$tahun	= $HTTP_GET_VARS['tahun'];
$nama	= $HTTP_GET_VARS['nama'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VPenilaian WHERE NIK='$nik' ) SELECT * FROM limit WHERE No='$no'",$conn);
	$row	= mssql_fetch_array($query);
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Save";
}

$show = $HTTP_GET_VARS['show'];
include("../header.php");
?>
<script type="text/javascript">
	
	MaskInput = function(f, m){
	function mask(e){
		var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
			rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
		function accept(c, rule){
			for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
				if(r & i && patterns[i].test(c))
					break;
				return i <= r || c == rule;
		}
		var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
		(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
			r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
			: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
			r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
	}
	for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
		addEvent(f, i, mask);
};

	function Validate(){

		if(document.forms[0].nik.value == ""){
			alert("Maaf, NIK tidak boleh kosong ...");
			document.forms[0].nik.focus();
			return false;
		}

		if(document.forms[0].tahun.value == ""){
			alert("Maaf, Tahun tidak boleh kosong ...");
			document.forms[0].tahun.focus();
			return false;
		}
		
		if(document.forms[0].unsur.value == ""){
			alert("Maaf, Unsur Penilaian harus dipilih ...");
			document.forms[0].unsur.focus();
			return false;
		}
		
		if(document.forms[0].nilai1.value == ""){
			alert("Maaf, Nilai 1 harus dipilih ...");
			document.forms[0].nilai1.focus();
			return false;
		}
		
		if(document.forms[0].nilai2.value == ""){
			alert("Maaf, Nilai 2 harus dipilih ...");
			document.forms[0].nilai2.focus();
			return false;
		}


		if(document.forms[0].nilai3.value == ""){
			alert("Maaf, Nilai 3 harus dipilih ...");
			document.forms[0].nilai3.focus();
			return false;
		}
		
		
		document.forms[0].submit();
	}
	
	function show_popup(page)
	{
		child = open
		(
			"frm_list_emp.php",
			"",
			"scrollbars,width=400,height=400,left=150,top=150"
		);
	}
</script>
</head>
<table width="100%">
 <tr>
  <td class="line_bottom">&nbsp;&nbsp;<b>CUTI KARYAWAN</b></td>
 </tr>
</table>
<?
	// untuk input data penilaian 
	//if(){
	
	//}
	
	// untuk edit data penilaian
	//elseif($op == "edit"){
?>
<form method="post" action="<?=$Faction?>">
<table width="91%" style="position:relative; left:80px;">
 <tr>
  <td colspan="2">
   <table>
    <tr>
	 <td width="110">NIK</td>
	 <td><input type="text" name="nik" value="<?=$nik?>" readonly=""/>
	<?
		if($HTTP_GET_VARS['nik'] == NULL ){
			echo"<a href='Javascript:show_popup()'><img src='../images/people.png' border=0></a>";
		}
	?>
	 </td>
	</tr>
    <tr>
	 <td>Nama</td>
	 <td><input type="text" name="nama" size="45" value="<?=$nama?>" readonly="" /></td>
	</tr>	
   </table>
  </td>
 </tr>
 <tr>
  <td colspan="2"><hr noshade="noshade" size="-2"/></td>
 </tr>
 <tr>
  <td valign="top" colspan="2">
  <table width="100%">
 <tr>
  <td width="100%">
   <fieldset><legend>HISTORY CUTI TAHUNAN</legend>
   <table>
    <tr class="headlist">
	 <td width="50">Periode</td>
	 <td width="200">Tanggal Cuti</td>
	 <td width="150">Keterangan</td>
	 <td width="150">Tunda</td>
     <td width="150">Ambil</td>
     <td width="150">Tanggal Hangus</td>
	</tr>
	<tr>
	 <td>&nbsp;</td>
	 <td>&nbsp;</td>
	 <td>&nbsp;</td>
	 <td>&nbsp;</td>	 	 	 
	</tr>
   </table>
   </fieldset>
  </td>
 </tr>
 </table>
 </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
  <td align="right">
  <input type="hidden" name="cat" value="penilaian" />
  <input type="hidden" name="no" value="<?=$row[No]?>" />
  <input type="button" value="Cancel" class="button" onclick="Javascript:history.back();" />
  <input type="button" value="Tambah" class="button" />
  <input type="button" value="<?=$Vbutton?>" class="button" onclick="Javascript:Validate();" />
  </td>
 </tr>
</table>
</form>

</td>
</tr>

<tr>
 <td colspan="2" style="border:none;"><? include("../footer.php"); ?></td>
</tr>
</table>
</body>
<script type="text/javascript">

var f = document.forms[0];
MaskInput(f.tahun,"9999");
//]]>
</script>
</body>
</html>
